package com.globant.util.log;

import java.io.File;

import org.springframework.dao.DataAccessException;

/**
 * Interface for the log functionalities.
 * 
 * @author gonzalo.zarza
 * @version 20130130v1.0
 */

public interface ILogFunctions {

	/* 
	================================================================================================
	 Fields
	================================================================================================
	*/
	public static final int    DEFAULT_REPORT_STATUS   = 4;            // should be mapped to pending?
	public static final float  DEFAULT_LOG_EFFICIENCY  = 0.0f; 
    public static final int    REPORTS_NUMBER          = 5;
    public static final int    REPORT_STATUS_COMPLETED = 1;
	
	public static final String DETAIL_STATUS_STARTING  = "STARTING";	
	public static final String DETAIL_STATUS_PENDING   = "PENDING";
	public static final String DETAIL_STATUS_STORING   = "STORING INFO";
	public static final String DETAIL_STATUS_FAILED    = "FAILED";
	public static final String DETAIL_STATUS_COMPLETED = "COMPLETED";
	
	public static final int    SQL_STATUS_COMPLETED    = 1;
    public static final int    SQL_STATUS_FAILED       = 2;
    public static final int    SQL_STATUS_PENDING      = 3;
    
    public static final String REPORT_NAME_TRAFFIC     = "akn_traffic_fact/";
    public static final String REPORT_NAME_SESSION     = "akn_session_fact/";
    public static final String REPORT_NAME_WORD        = "akn_word_fact/";
    public static final String REPORT_NAME_QUERY       = "akn_query_fact/";
    public static final String REPORT_NAME_NO_RESULT   = "akn_noresultquery_fact/";
	
	
	/* 
	================================================================================================
	 Methods
	================================================================================================
	*/
	
	/**
	 * Inserts a new log entry into the log details table.
	 * 
	 * @param logFile                  the file containing the log information 
	 * @throws DataAccessException     if cannot complete the operation
	 */
	public void setLogInformation(File logFile) throws DataAccessException;
	
	/* ------------------------------------------------------------------------------------------ */
	
	/**
	 * Updates the status information of the record corresponding to the given report and log (in the reports table).
	 * 
	 * @param logId                    the log id
	 * @param reportId                 the report id
	 * @param newStatus                the new status to set
	 * @throws DataAccessException     if cannot complete the operation
	 */
	public void updateReportStatusInformation(String logId, int reportId, int newStatus) throws DataAccessException;
	
	/* ------------------------------------------------------------------------------------------ */
    
	/**
	 * Updates the status information of the record corresponding to the given log id (in the log details table).
	 * 
	 * @param logName                  the log id
	 * @param newStatus                the new status to set
	 * @throws DataAccessException     if cannot complete the operation
	 */
    public void updateLogStatusInformation(String logId, String newStatus) throws DataAccessException;
	
    /* ------------------------------------------------------------------------------------------ */
    
    /**
     * Updates the efficiency information of log records whit status == completed and the given log id, 
     * according to the information obtained from the records table.
     * 
     * @param logId                     the log id
     * @throws DataAccessException      if cannot complete the operation
     */
    public void updateSingleEfficiencyInformation(String logId) throws DataAccessException;
    
	/* ------------------------------------------------------------------------------------------ */
	
    /**
     * Updates the efficiency information of log records whit status == completed, according to the information
     * obtained from the records table.
     * 
     * @throws DataAccessException      if cannot complete the operation
     */
	public void updateEfficiencyInformation() throws DataAccessException;	

	/* ------------------------------------------------------------------------------------------ */
	
	/**
	 * Deletes the log and report entries for the given log id.
	 *  
	 * @param logId                     the log id
	 * @throws DataAccessException      if cannot complete the operation
	 */
	public void deleteLogAndReportsById(String logId) throws DataAccessException;
	
}
